package com.rjj.wlqq.wxpay.wxpay.service;


import com.rjj.wlqq.wxpay.wxpay.WxPayKit;
import com.rjj.wlqq.wxpay.wxpay.entity.Wx;
import com.rjj.wlqq.wxpay.wxpay.entity.WxOrder;
import com.rjj.wlqq.wxpay.wxsdk.WXPayConstants;

/**
 * @author r
 * @date 2021/1/19 20:42
 */
public class WxPayService
{

    public static void main(String[] args)
    {
        orderTWO();
    }

    private static void orderTWO()
    {
        final WxOrder build = WxOrder.Builder()
                .setOut_trade_no("p123213123133332")
                .setTrade_type(WXPayConstants.TradeType.JSAPI.toString())
                .setOpenid("ocd6D1hlq-Goo9DOZcXhzinAbz68")
                .setTotal_fee("0.01")
                .setBody("测试商品")
                .setSpbill_create_ip("127.0.0.1")
                .setNotify_url("http://reg.dev.tcm166.cn/pay/wx/notify")
                .build();
        WxPayKit wxPayKit = new WxPayKit()
        {
            @Override
            public Wx initWx()
            {
                return Wx.builder()
                        .appId("wx6aa1dbb87873f9cf")
                        .mchId("1605435869")
                        .key("vG8xK6oH4fP3yN0sY1oH9HH2PK4tJ8xK")
                        .pathFile("/Users/renjianjun/study/ideaWorkSpace/gyzx-master/pay/fengqing_wx_apiclient_cert.p12")
                        .build();
            }
        };
        wxPayKit.unifiedorder(build);
    }

    private static void orderOne()
    {
        String orderNo = "p20211111111111";
        String tradeType = "JSAPI";
        String openId = "ocd6D1hlq-Goo9DOZcXhzinAbz68";
        String money = "1";
        boolean profitSharing = false;
        String ip = "127.0.0.1";
        String attach = "测试商品";
        String notifyUrl = "http://reg.dev.tcm166.cn/pay/wx/notify";
        String body = orderNo;
        WxPayKit wxPayKit = new WxPayKit()
        {
            @Override
            public Wx initWx()
            {
                return Wx.builder()
                        .appId("wx6aa1dbb87873f9cf")
                        .mchId("1605435869")
                        .key("vG8xK6oH4fP3yN0sY1oH9HH2PK4tJ8xK")
                        .pathFile("/Users/renjianjun/study/ideaWorkSpace/gyzx-master/pay/fengqing_wx_apiclient_cert.p12")
                        .build();
            }
        };
        wxPayKit.unifiedorder(orderNo, tradeType, openId, money, profitSharing, ip, attach, notifyUrl, body);
    }
}
